/********************************************************************************
* @Author: Zhenzhou Liu
* @Date: 2024-11-17
* @Description: Cg贪心之最多苹果数
* TODO：测试结果设置错误，586之后的数据是多余的
********************************************************************************/
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

struct Apple
{
    int height;
    int effort;

    Apple(): height(0), effort(0){}

    Apple(int height, int effort): height(height), effort(effort){}

    bool operator < (const Apple& temp) const
    {
        return effort < temp.effort;
    }
};

int maxApples(vector<Apple>& apples, int b, int s)
{
    sort(apples.begin(), apples.end());
    int count = 0;
    for (Apple& item : apples)
    {
        if (s >= item.effort)
        {
            if (item.height <= b)
            {
                s -= item.effort;
                ++count;
            }
        } else
            break;
    }
    return count;
}

int main()
{
    int n, s, a, b;
    cin >> n >> s >> a >> b;
    vector<Apple> apples(n);
    for (int i = 0; i < n; ++i)
    {
        int xi, yi;
        cin >> xi >> yi;
        apples[i].height = xi - a;
        apples[i].effort = yi;
    }
    cout << maxApples(apples, b, s);
    return 0;
}